import random
'''
随机生成训练集和验证集
'''
_NUM_VALIDATION = 350  # 这个验证集数量随意
_RANDOM_SEED = 0

list_path = 'list.txt'
train_list_path = 'list_train.txt'
val_list_path = 'list_val.txt'

with open(list_path, 'r') as f:
    lines = f.readlines()
random.seed(_RANDOM_SEED)
random.shuffle(lines)
with open(train_list_path, 'w') as f:
    for line in lines[_NUM_VALIDATION:]:
        f.write(line)
with open(val_list_path, 'w') as f:
    for line in lines[:_NUM_VALIDATION]:
        f.write(line)
